Skip to content

DEVOPS-853: check jira issue#147

Open
andrewg-mira wants to merge 16 commits intomainfrom
DEVOPS-853-check-jira-issue
Open

DEVOPS-853: check jira issue#147
andrewg-mira wants to merge 16 commits intomainfrom
DEVOPS-853-check-jira-issue

Conversation

@andrewg-mira
Copy link
Contributor

@andrewg-mira andrewg-mira commented Dec 12, 2025

DEVOPS-853 - Update Jenkinslib -- Jira API for querying issues is deprecated

@github-actions github-actions bot changed the title DEVOPS-853 check jira issue DEVOPS-853: check jira issue Dec 12, 2025
@andrewg-mira andrewg-mira requested a review from sebhmg December 12, 2025 18:04
- name: Check issue key
if: ${{ !steps.jira_key_from_title.outputs.issue_key }}
run: |
echo "Could not determine Jira issue from PR title"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably TODO: add exceptions for Dependabot etc PRs.

@sebhmg sebhmg force-pushed the DEVOPS-853-check-jira-issue branch from 10650e3 to 4d59de0 Compare December 12, 2025 19:22
Copy link
Contributor

@sebhmg sebhmg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see suggestion to merge workflows, and use a more specific pattern

Copy link
Contributor

@sebhmg sebhmg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, see questions and suggestions

@andrewg-mira andrewg-mira force-pushed the DEVOPS-853-check-jira-issue branch 4 times, most recently from 07482e7 to 23cb0e6 Compare January 26, 2026 21:50
@andrewg-mira andrewg-mira force-pushed the DEVOPS-853-check-jira-issue branch 2 times, most recently from aa29b27 to e35cfc1 Compare January 27, 2026 19:39
@andrewg-mira andrewg-mira force-pushed the DEVOPS-853-check-jira-issue branch from e35cfc1 to 866e558 Compare January 27, 2026 19:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds/updates reusable GitHub Actions workflows intended to extract a Jira issue key from a PR/branch, optionally update the PR with the Jira summary, and enforce Jira sprint/status requirements using the newer Jira JQL search endpoint.

Changes:

  • Added reusable workflow to validate a Jira issue is in an open/future sprint and “In Progress” via Jira REST API v3 JQL search.
  • Hardened/adjusted the reusable “add Jira summary” workflow trigger conditions and token permissions handling.
  • Introduced a combined reusable workflow that both updates PR content from Jira and validates Jira status.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.

File Description
.github/workflows/reusable-jira-pr_check_issue.yml New reusable workflow to derive Jira key (currently title-only) and validate sprint/status via Jira JQL search endpoint.
.github/workflows/reusable-jira-pr_add_jira_summary.yml Adds permissions: {} and job gating; impacts ability to update PR via GitHub API.
.github/workflows/reusable-jira-pr_actions.yml New “all-in-one” reusable workflow combining issue key extraction, PR update from Jira summary, and status enforcement.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 135 to 145
response=$(curl -s --request GET \
--url "$JIRA_BASE_URL/rest/api/3/search/jql?jql=$jqlencoded&fields=statusCategory" \
--user "${JIRA_USER_EMAIL}:${JIRA_API_TOKEN}" \
--header 'Accept: application/json' \
--header 'Content-Type: application/json')

if [ $? -ne 0 ]; then
echo "Jira API: error"
exit 1
fi

Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Jira API calls use curl -s and only check $?, which won’t catch HTTP 4xx/5xx responses (curl still exits 0). Consider using -fS (or capturing the HTTP status code) and validating the JSON response for Jira errors so the workflow fails reliably on API errors.

Suggested change
response=$(curl -s --request GET \
--url "$JIRA_BASE_URL/rest/api/3/search/jql?jql=$jqlencoded&fields=statusCategory" \
--user "${JIRA_USER_EMAIL}:${JIRA_API_TOKEN}" \
--header 'Accept: application/json' \
--header 'Content-Type: application/json')
if [ $? -ne 0 ]; then
echo "Jira API: error"
exit 1
fi
response=$(curl -fsS --request GET \
--url "$JIRA_BASE_URL/rest/api/3/search/jql?jql=$jqlencoded&fields=statusCategory" \
--user "${JIRA_USER_EMAIL}:${JIRA_API_TOKEN}" \
--header 'Accept: application/json' \
--header 'Content-Type: application/json')
if [ $? -ne 0 ]; then
echo "Jira API: HTTP request failed"
exit 1
fi
if ! echo "$response" | jq -e . > /dev/null 2>&1; then
echo "Jira API: invalid JSON response"
exit 1
fi

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using curl -fsS sounds a good suggestion to better capture error cases

runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
issue_key_from_branch: ${{ steps.issue_key_from_branch.outputs.issue_key }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
issue_key_from_branch: ${{ steps.issue_key_from_branch.outputs.issue_key }}
issue_key: ${{ steps.issue_key_from_title.outputs.issue_key || steps.issue_key_from_branch.outputs.issue_key }}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sugggestion: keep only issue_key, and remove issue_key_from_branch and issue_key_from_title

"$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/pulls/${{ github.event.pull_request.number }}"
> /dev/null

check_jira_issue:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skip the whole workflow if a dependbot PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possibly not needed to filter out dependabot PRs, as not finding a JIRA issue it not an error

but could the regex match something from the dependabot branch or PR title, which would then fail when requesting JIRA and thus mark the PR as failed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hence, my earlier suggestion of a stricter regex, using a secret that would list all the expected JIRA keys.
E.g.: "\b(NI|SHRUB|BEAST|AARG|SWALLOW|TIM|BRIDGE)[-# ]*([0-9]+)"

andrewg-mira and others added 2 commits February 13, 2026 11:23
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

@sebhmg sebhmg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please see suggestion from slight adjustments

Also, pending question about handling dependabot PRs (or those from Laravel Shift)

runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
issue_key_from_branch: ${{ steps.issue_key_from_branch.outputs.issue_key }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sugggestion: keep only issue_key, and remove issue_key_from_branch and issue_key_from_title


steps:

- name: Get JIRA summary from branch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: Get JIRA summary from branch
- name: Get JIRA issue summary

Comment on lines 135 to 145
response=$(curl -s --request GET \
--url "$JIRA_BASE_URL/rest/api/3/search/jql?jql=$jqlencoded&fields=statusCategory" \
--user "${JIRA_USER_EMAIL}:${JIRA_API_TOKEN}" \
--header 'Accept: application/json' \
--header 'Content-Type: application/json')

if [ $? -ne 0 ]; then
echo "Jira API: error"
exit 1
fi

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using curl -fsS sounds a good suggestion to better capture error cases

"$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/pulls/${{ github.event.pull_request.number }}"
> /dev/null

check_jira_issue:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possibly not needed to filter out dependabot PRs, as not finding a JIRA issue it not an error

but could the regex match something from the dependabot branch or PR title, which would then fail when requesting JIRA and thus mark the PR as failed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants